package org.elsfs.cloud.common.mybatis.ext.sql.support.condition;


import lombok.RequiredArgsConstructor;
import org.elsfs.cloud.common.util.lang.NamingCase;

/**
 * 字段条件
 *
 */
@RequiredArgsConstructor
public class FieldConditionItem implements ConditionItem {

    /**
     * 左边字段名称
     */
    private final String leftField;
    /**
     * 右边字段名称
     */
    private final String rightField;
    /**
     * 比较操作符
     */
    private final CompareOperator compareOperator;

    /**
     * 构建SQL片段
     *
     * @return SQL片段
     */
    @Override
    public String buildSqlFragment() {
        return NamingCase.toUnderlineCase(this.leftField) + this.compareOperator.getOperator() + NamingCase.toUnderlineCase(this.rightField);
    }
}
